<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('输送机测试')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="btn-group-sm" id="toolbar" role="group">
            <a id="save" class="btn btn-primary btn-rounded btn-sm"><i
            ></i>&nbsp;保存数据</a>
        </div>
        <div id="div" style="height: 100%;text-align: center" class="col-sm-12 select-table striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('search:IssueReceiptFlow:edit')}]];
    var removeFlag = [[${@permission.hasPermi('search:IssueReceiptFlow:remove')}]];
    var prefix = ctx + "db/Ssjdb";
    $(function () {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            // clickToSelect: true,//是否启用点击选中行
            height: $("#div").height() / 1,
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            modalName: "输送机测试",
            columns: [
                // {
                //     checkbox: true,
                //
                // },
                {
                    field: 'ckkx',
                    title: '出库空闲',
                    visible: true
                },
                {
                    field: 'dqrwh',
                    title: '当前任务号',
                    visible: true
                },
                {
                    field: 'dqbjxx',
                    title: '当前报警信息',
                    visible: true
                },
                {
                    field: 'scxfrwh',
                    title: '上次下发任务号',
                    visible: true
                },
                {
                    field: 'rkqq',
                    title: '入库请求',
                    visible: true
                },
                {
                    field: 'gd',
                    title: '高度',
                    visible: true
                },
                {
                    field: 'qqtm',
                    title: '请求条码',
                    visible: true
                },
                {
                    field: 'qqrwh',
                    title: '请求任务号',
                    visible: true
                },
                {
                    field: 'xfrwh',
                    title: '下发任务号',
                    visible: true
                },
                {
                    field: 'xfqx',
                    title: '下发去向',
                    visible: true
                },
                {
                    field: 'xfwc',
                    title: '下发完成',
                    visible: true
                },
                {
                    field: 'jym',
                    title: '校验码',
                    visible: true
                },

            ],
            onClickCell: function (field, value, row, $element) {
                $element.attr('contenteditable', true);
                $element.blur(function () {
                    let tdValue = $element.html();
                    tdValue=tdValue.replace(/<br>/g, "")
                    switch (field) {
                        case "ckkx":
                            row.ckkx = tdValue;
                            break;
                        case "dqrwh":
                            row.dqrwh = tdValue;
                            break;
                        case "dqbjxx":
                            row.dqbjxx = tdValue;
                            break;
                        case "scxfrwh":
                            row.scxfrwh = tdValue;
                            break;
                        case "rkqq":
                            row.rkqq = tdValue;
                            break;
                        case "gd":
                            row.gd = tdValue;
                            break;
                        case "qqtm":
                            row.qqtm = tdValue;
                            break;
                        case "qqrwh":
                            row.qqrwh = tdValue;
                            break;
                        case "xfrwh":
                            row.xfrwh = tdValue;
                            break;
                        case "xfqx":
                            row.xfqx = tdValue;
                            break;
                        case "xfwc":
                            row.xfwc = tdValue;
                            break;
                        case "jym":
                            row.jym = tdValue;
                            break;
                    }
                })


            }
        };
        $.table.init(options);
    });

    $("#save").click(function () {
        var data = $("#bootstrap-table").bootstrapTable('getData');

        for (let i = 0; i < data.length; i++) {
            var shuju = "Ddjdb/edit?CKKX=" + data[i].ckkx + "&DQRWH=" + data[i].dqrwh + "&DQBJXX=" + data[i].dqbjxx + "&SCXFRWH=" +
                data[i].scxfrwh + "&RKQQ=" + data[i].rkqq + "&GD=" + data[i].gd + "&QQTM=" + data[i].qqtm + "&QQRWH=" +
                data[i].qqrwh + "&XFRWH=" + data[i].xfrwh +"&XFQX=" + data[i].xfqx + "&XFWC=" + data[i].xfwc + "&JYM=" + data[i].jym
            console.log(shuju)
            $.ajax({
                url: shuju,       //后台地址
                contentType: 'application/json',
                type: 'post',
                // data: JSON.stringify(info),
                dataType: 'json',
                success: function callbackss(data) {
                    location.reload()

                }
            })
        }
    })
</script>
</body>
</html>